package org.nci.platform.workflow.expand.system.service.impl;

import com.alibaba.fastjson2.JSON;
import gh.priv.general.common.vo.PageResult;
import org.nci.platform.workflow.dto.FlowUserPageQuery;
import org.nci.platform.workflow.dto.FlowUserQuery;
import org.nci.platform.workflow.expand.system.entity.WorkflowUser;
import org.nci.platform.workflow.expand.system.service.WorkflowUserService;

import java.util.List;
import java.util.Objects;

public class DemoUserImpl implements WorkflowUserService {
    String data="[{\"id\":1,\"userId\":\"user_1001\",\"dept\":{\"deptId\":\"dept_2001\",\"deptName\":\"前厅部\"},\"roles\":[{\"roleId\":\"role_3001\",\"roleName\":\"前台接待\"}],\"userName\":\"张明\",\"nickName\":\"小明\"},{\"id\":2,\"userId\":\"user_1002\",\"dept\":{\"deptId\":\"dept_2001\",\"deptName\":\"前厅部\"},\"roles\":[{\"roleId\":\"role_3001\",\"roleName\":\"前台接待\"}],\"userName\":\"李华\",\"nickName\":\"华华\"},{\"id\":3,\"userId\":\"user_1003\",\"dept\":{\"deptId\":\"dept_2002\",\"deptName\":\"客房部\"},\"roles\":[{\"roleId\":\"role_3002\",\"roleName\":\"客房服务\"}],\"userName\":\"王芳\",\"nickName\":\"芳芳\"},{\"id\":4,\"userId\":\"user_1004\",\"dept\":{\"deptId\":\"dept_2002\",\"deptName\":\"客房部\"},\"roles\":[{\"roleId\":\"role_3002\",\"roleName\":\"客房服务\"}],\"userName\":\"赵强\",\"nickName\":\"强哥\"},{\"id\":5,\"userId\":\"user_1005\",\"dept\":{\"deptId\":\"dept_2003\",\"deptName\":\"餐饮部\"},\"roles\":[{\"roleId\":\"role_3003\",\"roleName\":\"餐饮服务\"}],\"userName\":\"陈静\",\"nickName\":\"静静\"},{\"id\":6,\"userId\":\"user_1006\",\"dept\":{\"deptId\":\"dept_2003\",\"deptName\":\"餐饮部\"},\"roles\":[{\"roleId\":\"role_3003\",\"roleName\":\"餐饮服务\"}],\"userName\":\"刘伟\",\"nickName\":\"伟哥\"},{\"id\":7,\"userId\":\"user_1007\",\"dept\":{\"deptId\":\"dept_2004\",\"deptName\":\"财务部\"},\"roles\":[{\"roleId\":\"role_3004\",\"roleName\":\"财务管理\"}],\"userName\":\"杨丽\",\"nickName\":\"丽丽\"},{\"id\":8,\"userId\":\"user_1008\",\"dept\":{\"deptId\":\"dept_2004\",\"deptName\":\"财务部\"},\"roles\":[{\"roleId\":\"role_3004\",\"roleName\":\"财务管理\"}],\"userName\":\"周涛\",\"nickName\":\"涛哥\"},{\"id\":9,\"userId\":\"user_1009\",\"dept\":{\"deptId\":\"dept_2005\",\"deptName\":\"行政部\"},\"roles\":[{\"roleId\":\"role_3005\",\"roleName\":\"行政管理\"}],\"userName\":\"吴刚\",\"nickName\":\"刚子\"},{\"id\":10,\"userId\":\"user_1010\",\"dept\":{\"deptId\":\"dept_2005\",\"deptName\":\"行政部\"},\"roles\":[{\"roleId\":\"role_3005\",\"roleName\":\"行政管理\"}],\"userName\":\"郑秀英\",\"nickName\":\"英子\"},{\"id\":11,\"userId\":\"user_1011\",\"dept\":{\"deptId\":\"dept_2001\",\"deptName\":\"前厅部\"},\"roles\":[{\"roleId\":\"role_3001\",\"roleName\":\"前台接待\"}],\"userName\":\"孙经理\",\"nickName\":\"孙总\"},{\"id\":12,\"userId\":\"user_1012\",\"dept\":{\"deptId\":\"dept_2003\",\"deptName\":\"餐饮部\"},\"roles\":[{\"roleId\":\"role_3003\",\"roleName\":\"餐饮服务\"}],\"userName\":\"钱大厨\",\"nickName\":\"钱师傅\"}]";
    @Override
    public List<WorkflowUser> selectUserList(FlowUserQuery user) {
        return JSON.parseArray(data,WorkflowUser.class);
    }

    @Override
    public WorkflowUser selectUserById(String userId) {
        List<WorkflowUser> workflowUsers = selectUserList(null);
        return workflowUsers.stream().filter(u-> Objects.equals(u.getUserId(), userId)).findFirst().orElse(new WorkflowUser());
    }

    @Override
    public PageResult<WorkflowUser> selectUserPage(FlowUserPageQuery query) {
        List<WorkflowUser> workflowUsers = selectUserList(null);
        return PageResult.of(workflowUsers,workflowUsers.size(), workflowUsers.size(), 1);
    }
}
